//
//  LGFollowDataSyptomCell.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/6/21.
//

#import "LGFollowDataSymptomCell.h"

#define baseWidth     (Screen_W-viewPix(56))
#define symptomWidth  (65/320.0)*baseWidth
#define startWidth    (103/320.0)*baseWidth
#define endWidth      (103/320.0)*baseWidth

@interface LGFollowDataSymptomCell()
/**   */
@property (nonatomic , strong)UIView *shadowView;
/**   */
@property (nonatomic , strong)UIView *baseView;
/**   */
@property (nonatomic , strong)UIView *topLineView;
/**   */
@property (nonatomic , strong)UIView *lineView1;
/**   */
@property (nonatomic , strong)UIView *lineView2;
/**   */
@property (nonatomic , strong)UIView *lineView3;
/**   */
@property (nonatomic , strong)UILabel *symptomLabel;
/**   */
@property (nonatomic , strong)UILabel *startLabel;
/**   */
@property (nonatomic , strong)UILabel *endLabel;
/**   */
@property (nonatomic , strong)UILabel *continueLabel;

@end

@implementation LGFollowDataSymptomCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return  self;
}

-(void)setShowCorner:(BOOL)showCorner{
    _showCorner = showCorner;
    CGFloat bottom = (showCorner == YES)?-viewPix(10):0;
    [self.baseView mas_updateConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.shadowView).offset(bottom);
    }];
}

-(void)setDataDic:(NSDictionary *)dataDic{
    _dataDic = dataDic;
    self.symptomLabel.text = LGNSString(dataDic[@"symptom_name"]);
    self.startLabel.text = LGNSString(dataDic[@"start_date"]);
    self.endLabel.text = LGNSString(dataDic[@"end_date"]);
    self.continueLabel.text = [NSString stringWithFormat:@"%@天",dataDic[@"days"]];
}

#pragma mark
#pragma mark ====> 创建控件
-(void)createSubView{
    self.clipsToBounds = YES;
    self.backgroundColor = [UIColor colorWithString:@"#F9F9F9"];
    [self.contentView addSubview:self.shadowView];
    [self.shadowView addSubview:self.baseView];
    [self.shadowView addSubview:self.topLineView];
    [self.baseView addSubview:self.symptomLabel];
    [self.baseView addSubview:self.startLabel];
    [self.baseView addSubview:self.endLabel];
    [self.baseView addSubview:self.continueLabel];
    [self.baseView addSubview:self.lineView1];
    [self.baseView addSubview:self.lineView2];
    [self.baseView addSubview:self.lineView3];
    [self.shadowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(-viewPix(5));
        make.left.equalTo(self.contentView).offset(viewPix(16));
        make.right.equalTo(self.contentView).offset(-viewPix(16));
        make.bottom.equalTo(self.contentView).offset(viewPix(5));
    }];
    [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.shadowView).offset(viewPix(12));
        make.right.equalTo(self.shadowView).offset(-viewPix(12));
        make.top.equalTo(self.shadowView);
        make.bottom.equalTo(self.shadowView).offset(0);
        make.height.equalTo(@(viewPix(40)));
    }];
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.baseView);
        make.top.equalTo(self.contentView);
        make.height.equalTo(@(0.5));
    }];
    [self.symptomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.left.equalTo(self.baseView);
        make.width.equalTo(@(symptomWidth));
    }];
    [self.startLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.symptomLabel);
        make.left.equalTo(self.symptomLabel.mas_right);
        make.width.equalTo(@(startWidth));
    }];
    [self.endLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.symptomLabel);
        make.left.equalTo(self.startLabel.mas_right);
        make.width.equalTo(@(endWidth));
    }];
    [self.continueLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(self.symptomLabel);
        make.left.equalTo(self.endLabel.mas_right);
        make.right.equalTo(self.baseView);
    }];
    [self.lineView1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.symptomLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.startLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
    [self.lineView3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.equalTo(self.baseView);
        make.left.equalTo(self.endLabel.mas_right);
        make.width.equalTo(@(0.5));
    }];
}
-(UIView *)shadowView{
    if(!_shadowView){
        _shadowView = [UIView shadowViewWithColor:@"#B3C5D9" offset:CGSizeMake(0, 2) opacity:0.15 radius:10];
        _shadowView.backgroundColor = [UIColor whiteColor];
    }
    return _shadowView;
}


-(UIView *)baseView{
    if(!_baseView){
        _baseView = [[UIView alloc] init];
        _baseView.layer.borderColor = [UIColor colorWithString:@"#E0E0E0"].CGColor;
        _baseView.layer.borderWidth = 1;
        _baseView.cornerRidus = 7;
    }
    return _baseView;
}

-(UIView *)topLineView{
    if(!_topLineView){
        _topLineView = [[UIView alloc] init];
        _topLineView.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _topLineView;
}

-(UIView *)lineView1{
    if(!_lineView1){
        _lineView1 = [[UIView alloc] init];
        _lineView1.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView1;
}


-(UIView *)lineView2{
    if(!_lineView2){
        _lineView2 = [[UIView alloc] init];
        _lineView2.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView2;
}

-(UIView *)lineView3{
    if(!_lineView3){
        _lineView3 = [[UIView alloc] init];
        _lineView3.backgroundColor = [UIColor colorWithString:@"#E0E0E0"];
    }
    return _lineView3;
}

-(UILabel *)symptomLabel{
    if(!_symptomLabel){
        _symptomLabel = [UILabel lableWithText:@"症状" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _symptomLabel;
}

-(UILabel *)startLabel{
    if(!_startLabel){
        _startLabel = [UILabel lableWithText:@"出现时间" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _startLabel;
}

-(UILabel *)endLabel{
    if(!_endLabel){
        _endLabel = [UILabel lableWithText:@"结束时间" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _endLabel;
}


-(UILabel *)continueLabel{
    if(!_continueLabel){
        _continueLabel = [UILabel lableWithText:@"持续" colorString:@"#666666" textFont:LGFont(12) textAlignment:NSTextAlignmentCenter lines:1];
    }
    return _continueLabel;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
